package utils;

import cn.hutool.core.lang.Console;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

/**
 * Created By  醉美柳舞之众星捧月
 *
 * @author 宋贤坤
 * @date 2019/3/26 15:17
 */
public class FirstUtil {
    private static final String STR = "{\n" +
            "  \"code\": 0,\n" +
            "  \"msg\": \"success\",\n" +
            "  \"ts\": 1553592572914,\n" +
            "  \"data\": {\n" +
            "    \"size\": 0,\n" +
            "    \"couponObjects\": {\n" +
            "      \"id\": null,\n" +
            "      \"idS\": null,\n" +
            "      \"code\": null,\n" +
            "      \"name\": null,\n" +
            "      \"type\": null,\n" +
            "      \"typeDes\": null,\n" +
            "      \"sceneDes\": null,\n" +
            "      \"scene\": null,\n" +
            "      \"loseType\": 0,\n" +
            "      \"days\": 0,\n" +
            "      \"limitSum\": null,\n" +
            "      \"usedSum\": null,\n" +
            "      \"useCycle\": null,\n" +
            "      \"floorSill\": null,\n" +
            "      \"denomination\": null,\n" +
            "      \"openRegisTime\": null,\n" +
            "      \"closeRegisTime\": null,\n" +
            "      \"effectiveTime\": null,\n" +
            "      \"loseTime\": null,\n" +
            "      \"enable\": true,\n" +
            "      \"hasReceive\": false,\n" +
            "      \"couponDesc\": null,\n" +
            "      \"couponTypes\": null,\n" +
            "      \"loseDate\": null,\n" +
            "      \"registerSum\": null,\n" +
            "      \"receiveLimit\": null,\n" +
            "      \"couponChannel\": null\n" +
            "    }\n" +
            "  }\n" +
            "}";

    public static void main(String[] args) {
        JSONObject jsonObject = JSONUtil.parseObj(STR);
        Console.error(jsonObject);

        Object data = jsonObject.get("data");
        JSONObject secondObject = JSONUtil.parseObj(data);
        Console.error(secondObject.get("size"));
        Object threeObject = secondObject.get("couponObjects");
        JSONObject couponObjects = JSONUtil.parseObj(threeObject);
        Console.error(couponObjects.get("enable"));
    }
}
